﻿intellisense.addEventListener('statementcompletion', function (e) {
    e.items.forEach(function (item) {
        // Detect a namespace by using the _isNamespace flag.
        if (item.value && item.value.typeOf == 'Namespace') {
            item.glyph = 'vs:GlyphGroupNamespace';
        }

        if (item.parentObject && item.parentObject.typeOf == 'Namespace') {
            // The item is a member of a namespace. 

            // All constructor functions that are part of a namespace 
            // are considered classes. 
            // A constructor function starts with
            // an uppercase letter by convention.  
            if (typeof item.value == 'function' && (item.name[0].toUpperCase()
                == item.name[0])) {
                item.glyph = 'vs:GlyphGroupClass';
            }

            // Detect an enumeration by using the _isEnum flag.
            if (item.value && item.value.typeOf == 'Enum') {
                item.glyph = 'vs:GlyphGroupEnum';
            }
        }
    });
});

intellisense.addEventListener('statementcompletionhint', function (e) {
    if (e.completionItem.value) {
        if (e.completionItem.value.typeOf == 'Namespace') {
            e.symbolHelp.symbolDisplayType = 'Namespace';
        }
        if (e.completionItem.value.typeOf == 'Enum') {
            e.symbolHelp.symbolDisplayType = 'Enum';
        }
    }
});